<?php

	error_reporting(E_ERROR);

	define('CURSCRIPT', 'forumdisplay');



    $dbHostname = "127.0.0.1";     //数据库地址

    $dbUsername = "root";          //数据库用户名

    $dbPassword  = "98154981";     //数据库密码

    $dbName       = "athlon_milk_order";    //数据库名:模板开始改用evolution数据库。20170103



global $table_Prefix;
$table_Prefix   ="athlon_";         //该工程的table前缀
global $table_prefix;
$table_prefix   ="athlon_";         //该工程的table前缀

            

    $dblink = MYSQLI_CONNECT($dbHostname, $dbUsername, $dbPassword) OR DIE("数据库连接失败!");
    mysqli_select_db($dblink,$dbName) or die( "Unable to select database ".$dbName);
    do_query("set names utf8mb4");



function do_query($sql) {
    global $dblink;

    $result = mysqli_query($dblink, $sql);

    if (!$result) {
        // 获取调用此函数的文件名和行号
        $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1);
        $file = isset($backtrace[0]['file']) ? $backtrace[0]['file'] : 'unknown file';
        $line = isset($backtrace[0]['line']) ? $backtrace[0]['line'] : 'unknown line';

        // 错误信息包含文件名、行号、SQL 错误信息等
        $error = "SQL Error in {$file} (line {$line}): "
                . mysqli_error($dblink) . " (" . mysqli_errno($dblink) . ") - SQL: {$sql}";

        // 写入日志
        error_log($error);

        // 页面输出（仅调试阶段开启）
        echo $error . "<br><br>";

        return false;
    }

    return $result;
}


?>